Skip to content

Add queue depth telemetry gauge#79

Merged
ChiragAgg5k merged 3 commits into
mainfrom
add-queue-depth-metric
May 14, 2026
Merged

Add queue depth telemetry gauge#79
ChiragAgg5k merged 3 commits into
mainfrom
add-queue-depth-metric

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

  • Adds a messaging.queue.depth gauge initialized with the queue server telemetry.
  • Records pending queue size on worker start and after each processed message when the consumer also implements Publisher::getQueueSize().
  • Covers the supported and unsupported consumer paths with an in-process server telemetry test.

Type of Change

  • New feature

Testing

  • vendor/bin/phpunit tests/Queue/E2E/Adapter/ServerTelemetryTest.php
  • vendor/bin/phpstan analyse src/Queue/Server.php tests/Queue/E2E/Adapter/ServerTelemetryTest.php --memory-limit=1G
  • vendor/bin/pint --test src/Queue/Server.php tests/Queue/E2E/Adapter/ServerTelemetryTest.php

Full vendor/bin/phpunit was attempted locally, but the AMQP E2E tests require the amqp:5672 service hostname and failed DNS resolution outside the Docker test environment.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR introduces a messaging.queue.depth gauge to the queue server's telemetry, recorded once at worker start and again after every processed message when the consumer also implements Publisher::getQueueSize(). A dedicated test file exercises the three key paths using lightweight in-process stubs so no external broker is needed.

  • src/Queue/Server.php: setTelemetry() now creates the gauge; the new private recordQueueDepth() guards on instanceof Publisher, calls getQueueSize(), and records the result with messaging.destination.name / messaging.destination.namespace attributes.
  • tests/Queue/E2E/Adapter/ServerTelemetryTest.php: Covers the publisher path (depth recorded), the non-publisher path (skipped), and the failure path (silently swallowed, no values recorded).

Confidence Score: 5/5

Safe to merge — the change is additive, guarded by an interface check, and does not alter any existing message-processing behavior.

The gauge is always initialized (constructor calls setTelemetry(new NoTelemetry())) so no uninitialized-property risk exists. The instanceof Publisher guard ensures nothing changes for consumers that do not support getQueueSize(). The finally-block placement means queue depth is captured after every message without interfering with the success/error callback flow. All three behavioral paths are covered by the new test.

No files require special attention.

Important Files Changed

Filename Overview
src/Queue/Server.php Adds messaging.queue.depth gauge, initialized in setTelemetry() and recorded on worker start and after each message's finally block via the new recordQueueDepth() helper. Logic is correct; silent Throwable catch was flagged in a previous review thread.
tests/Queue/E2E/Adapter/ServerTelemetryTest.php New in-process test covering three paths: publisher consumer records expected depths, non-publisher consumer records nothing, and a failing publisher consumer is silently swallowed and records nothing. Test stubs are self-contained and correct.

Reviews (3): Last reviewed commit: "Simplify queue depth error telemetry" | Re-trigger Greptile

Comment thread src/Queue/Server.php
@ChiragAgg5k ChiragAgg5k merged commit 141aad1 into main May 14, 2026
8 checks passed
@ChiragAgg5k ChiragAgg5k deleted the add-queue-depth-metric branch May 14, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants